<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>LMultitouch</title>
		<script type="text/javascript" src="../load_lufylegend.js"></script>
	</head>
	<body>
			<div id="legend">
			</div>
			<script>
			LInit(1000/50,"legend",800,450,main);
			var layer,backLayer,touchPointIDList = [];
			function main(){
				if(LGlobal.canTouch){
					LGlobal.stageScale = LStageScaleMode.EXACT_FIT;
					LSystem.screen(LStage.FULL_SCREEN);
				}
				LMultitouch.inputMode = LMultitouchInputMode.TOUCH_POINT;
			
				layer = new LSprite();
				layer.graphics.drawRect(2,"#ffffff",[0,0,LGlobal.width,LGlobal.height],true,"#ffffff");
				addChild(layer);
				backLayer = new LSprite();
				backLayer.y = 50;
				layer.addChild(backLayer);
				var txtLabel = new LTextField();
				txtLabel.size = 18;
				txtLabel.x = 10;
				txtLabel.y = 5;
				layer.addChild(txtLabel);
				if(!LGlobal.canTouch){
					txtLabel.text = "多点触屏测试：请用手机或平板电脑测试";
				}else{
					txtLabel.text = "多点触屏测试：请点击屏幕进行测试";
				}
				
				layer.addEventListener(LMouseEvent.MOUSE_DOWN,addTouchPointID);
				layer.addEventListener(LMouseEvent.MOUSE_MOVE,addTouchPointID);
				layer.addEventListener(LMouseEvent.MOUSE_UP,removeTouchPointID);
			}
			function addTouchPointID(e){
				var f = false;
				for(var i=0;i<touchPointIDList.length;i++){
					if(touchPointIDList[i].touchPointID == e.touchPointID){
						touchPointIDList[i] = e;
						f = true;
						break;
					}
				}
				if(!f)touchPointIDList.push(e);
				draw();
			}
			function removeTouchPointID(e){
				for(var i=0;i<touchPointIDList.length;i++){
					if(touchPointIDList[i].touchPointID == e.touchPointID){
						touchPointIDList.splice(i,1);
						break;
					}
				}
				draw();
			}
			function draw(){
				backLayer.removeAllChild();
				for(var i=0;i<touchPointIDList.length;i++){
					var eve = touchPointIDList[i];
					var title = new LTextField();
					title.text = "id:"+eve.touchPointID+","+eve.offsetX+","+eve.offsetY;
					title.size = 18;
					title.x = 10;
					title.y = i*23;
					backLayer.addChild(title);
				}
			}
			</script>
	</body>
</html>